//package lvtu.opencv.util;
//import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;
//import static com.googlecode.javacv.cpp.opencv_core.*;
//import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
//import static com.googlecode.javacv.cpp.opencv_imgproc.CV_BGR2GRAY;
//import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;
//import static com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects;
//
//import com.googlecode.javacv.cpp.opencv_core.CvMemStorage;
//import com.googlecode.javacv.cpp.opencv_core.CvSeq;
//import com.googlecode.javacv.cpp.opencv_core.IplImage;
//import com.googlecode.javacv.cpp.opencv_objdetect.CvHaarClassifierCascade;
//  
//public class FaceDetection {  
//  
//    // The cascade definition to be used for detection.  
//     
//    
//    private static final Double scale_factor = ConfigUtils.getScaleFactor(); 
//    
////    public static void main(String arg[]) throws Exception {  
////          
////  
////        // Load the original image.  
////        IplImage originalImage = cvLoadImage("/home/alex/a4.jpg",1);  
////  
////        // We need a grayscale image in order to do the recognition, so we  
////        // create a new image of the same size as the original one.  
////        IplImage grayImage = IplImage.create(originalImage.width(),  
////                originalImage.height(), IPL_DEPTH_8U, 1);  
////  
////        // We convert the original image to grayscale.  
////         cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);  
////  
////        CvMemStorage storage = CvMemStorage.create();  
////  
////        // We instantiate a classifier cascade to be used for detection, using  
////        // the cascade definition.  
////        CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(  
////                cvLoad(CASCADE_FILE));  
////  
////        // We detect the faces.  
////        CvSeq faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.5, 1,  
////                0);  
////  
////        // We iterate over the discovered faces and draw yellow rectangles  
////        // around them.  
////        if(faces.total() == 0){
////        	System.out.println("没有检测到人脸");
////        }else{
////        	System.out.println("检测到"+faces.total()+"张人脸");
////        }
////        	
////        for (int i = 0; i < faces.total(); i++) {  
////            CvRect r = new CvRect(cvGetSeqElem(faces, i));  
////            cvRectangle(originalImage, cvPoint(r.x(), r.y()),  
////                    cvPoint(r.x() + r.width(), r.y() + r.height()),  
////                    CvScalar.YELLOW, 1, CV_AA, 0);  
////  
////        }  
////  
////        // Save the image to a new file.  
////        cvSaveImage("/home/alex/new.jpg", originalImage);  
////  
////    }  
//    
//    public static  boolean isFace(String filename,CvHaarClassifierCascade cascade){
//    	
//    	
//    	//System.out.println("curr cascade------- "+CASCADE_FILE);
//    	// Load the original image.  
//        IplImage originalImage = cvLoadImage(filename,1);  
//        
//        // We need a grayscale image in order to do the recognition, so we  
//        // create a new image of the same size as the original one.  
//        IplImage grayImage = null;
//		try {
//			grayImage = IplImage.create(originalImage.width(),  
//			        originalImage.height(), IPL_DEPTH_8U, 1);
//			
//			
//		} catch (Exception e) {
//			return true;
//		}  
//  
//        
//		// We convert the original image to grayscale.  
//        cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);  
//        
//  
//  
//        CvMemStorage storage = CvMemStorage.create();  
//  
//        
//        // We instantiate a classifier cascade to be used for detection, using  
//        // the cascade definition.  q
//         
//        CvSeq faces = null;
//        // We detect the faces.  
//         faces = cvHaarDetectObjects(grayImage, cascade, storage, scale_factor, 1,  
//                0);  
//        //cvClearMemStorage(faces.storage());
//        int tag = faces.total();
//        cvReleaseImage(originalImage);
////        cvClearMemStorage(storage);
////        cvClearMemStorage(faces.storage());
////        storage.release();
////        storage = null;
////        faces = null;
//        	System.gc();
////        cvReleaseImage(originalImage);
//        // We iterate over the discovered faces and draw yellow rectangles  
//        // around them.  
//        if(tag == 0){
//        	//System.out.println("没有检测到人脸");
//        	return false;
//        }else{
////        	System.out.println("检测到"+faces.total()+"张人脸");
////        	
////        	 for (int i = 0; i < faces.total(); i++) {  
////                 CvRect r = new CvRect(cvGetSeqElem(faces, i));  
////                 cvRectangle(originalImage, cvPoint(r.x(), r.y()),  
////                         cvPoint(r.x() + r.width(), r.y() + r.height()),  
////                         CvScalar.YELLOW, 1, CV_AA, 0);  
////       
////             }  
////       
////             // Save the image to a new file.  
////             cvSaveImage(ConfigUtils.getTempPath()+System.currentTimeMillis()+".jpg", originalImage);  
//        	
//        	return true;
//        }
//    
//        
//    }
//  
//}